C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################
C
C$OPENAD XXX File_start [head.f]
      SUBROUTINE box_forward(ILEV1)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_0
      INTEGER(w2f__i8) OpenAD_Symbol_1
      INTEGER(w2f__i8) OpenAD_Symbol_10
      INTEGER(w2f__i8) OpenAD_Symbol_11
      INTEGER(w2f__i8) OpenAD_Symbol_2
      INTEGER(w2f__i8) OpenAD_Symbol_3
      INTEGER(w2f__i8) OpenAD_Symbol_4
      INTEGER(w2f__i8) OpenAD_Symbol_5
      INTEGER(w2f__i8) OpenAD_Symbol_6
      INTEGER(w2f__i8) OpenAD_Symbol_7
      INTEGER(w2f__i8) OpenAD_Symbol_8
      INTEGER(w2f__i8) OpenAD_Symbol_9
C
C     **** Parameters and Result ****
C
      INTEGER(w2f__i4) ILEV1
C
C     **** Local Variables and Functions ****
C
      EXTERNAL box_cycle_fields
      EXTERNAL box_density
      EXTERNAL box_robert_filter
      EXTERNAL box_timestep
      EXTERNAL box_transport
      INTEGER(w2f__i4) IKEY
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_151


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(ALPHA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(BETA,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_scalar(DELTA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(DELTA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(GAMMA_S,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(GAMMA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(ROBERT_FILTER_COEFF,theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_scalar(U0,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(UVEL%v,theArgFStack,theArgFStackoffset,t
     +heArgFStackSize)
      call cp_store_int_scalar(ILEV1,theArgIStack,theArgIStackoffset,the
     +ArgIStackSize)
      call cp_store_p_real_vector(FW,size(FW),theArgFStack,theArgFStacko
     +ffset,theArgFStackSize)
      call cp_store_p_real_vector(NULLFORCE,size(NULLFORCE),theArgFStack
     +,theArgFStackoffset,theArgFStackSize)
      call cp_store_real_vector(RHO,size(RHO),theArgFStack,theArgFStacko
     +ffset,theArgFStackSize)
      call cp_store_real_vector(SNEW,size(SNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SNOW,size(SNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SOLD,size(SOLD),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_p_real_vector(SSTAR,size(SSTAR),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(TNEW,size(TNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TNOW,size(TNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TOLD,size(TOLD),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_p_real_vector(TSTAR,size(TSTAR),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_p_real_vector(VOL,size(VOL),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(VOL,1),lbound(VOL,1),-1
      VOL(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TSTAR,1),lbound(TSTAR,1),-1
      TSTAR(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TOLD,1),lbound(TOLD,1),-1
      TOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TNOW,1),lbound(TNOW,1),-1
      TNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TNEW,1),lbound(TNEW,1),-1
      TNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SSTAR,1),lbound(SSTAR,1),-1
      SSTAR(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SOLD,1),lbound(SOLD,1),-1
      SOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNOW,1),lbound(SNOW,1),-1
      SNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNEW,1),lbound(SNEW,1),-1
      SNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(RHO,1),lbound(RHO,1),-1
      RHO(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(NULLFORCE,1),lbound(NULLFORCE,1),-1
      NULLFORCE(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FW,1),lbound(FW,1),-1
      FW(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      ILEV1 = theArgIStack(theArgIStackoffset)
      theArgIStackoffset = theArgIStackoffset-1
      UVEL%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      U0 = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ROBERT_FILTER_COEFF = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      GAMMA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      GAMMA_S = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      BETA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ALPHA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      IKEY = ILEV1
      CALL box_density(TNOW,SNOW,RHO)
      CALL box_transport(RHO,UVEL)
      CALL box_timestep(GAMMA_T,TSTAR,NULLFORCE,UVEL,TNOW,TOLD,TNEW)
      CALL box_timestep(GAMMA_S,SSTAR,FW,UVEL,SNOW,SOLD,SNEW)
      CALL box_robert_filter(TNOW,TOLD,TNEW)
      CALL box_robert_filter(SNOW,SOLD,SNEW)
      CALL box_cycle_fields()
      DO L = 1,3,1
        IF (TNOW(L)%v.LT.(-2.0D00)) THEN
          TNOW(INT(L))%v = 2.0D00
        ENDIF
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      IKEY = ILEV1
      CALL box_density(TNOW,SNOW,RHO)
      CALL box_transport(RHO,UVEL)
      CALL box_timestep(GAMMA_T,TSTAR,NULLFORCE,UVEL,TNOW,TOLD,TNEW)
      CALL box_timestep(GAMMA_S,SSTAR,FW,UVEL,SNOW,SOLD,SNEW)
      CALL box_robert_filter(TNOW,TOLD,TNEW)
      CALL box_robert_filter(SNOW,SOLD,SNEW)
      CALL box_cycle_fields()
      OpenAD_Symbol_3 = 0_w2f__i8
      DO L = 1,3,1
        IF (TNOW(L)%v.LT.(-2.0D00)) THEN
          TNOW(INT(L))%v = 2.0D00
          integer_tape(integer_tape_pointer) = L
          integer_tape_pointer = integer_tape_pointer+1
          OpenAD_Symbol_4 = 1_w2f__i8
          integer_tape(integer_tape_pointer) = OpenAD_Symbol_4
          integer_tape_pointer = integer_tape_pointer+1
        ELSE
          OpenAD_Symbol_5 = 0_w2f__i8
          integer_tape(integer_tape_pointer) = OpenAD_Symbol_5
          integer_tape_pointer = integer_tape_pointer+1
        ENDIF
        OpenAD_Symbol_3 = (INT(OpenAD_Symbol_3)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_3
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_0 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_1 = 1
      do while (INT(OpenAD_Symbol_1).LE.INT(OpenAD_Symbol_0))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_2 = integer_tape(integer_tape_pointer)
        IF (OpenAD_Symbol_2.ne.0) THEN
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_151 = integer_tape(integer_tape_pointer)
          TNOW(OpenAD_Symbol_151)%d = 0.0d0
        ENDIF
        OpenAD_Symbol_1 = INT(OpenAD_Symbol_1)+1
      END DO
      CALL box_cycle_fields()
      CALL box_robert_filter(SNOW,SOLD,SNEW)
      CALL box_robert_filter(TNOW,TOLD,TNEW)
      CALL box_timestep(GAMMA_S,SSTAR,FW,UVEL,SNOW,SOLD,SNEW)
      CALL box_timestep(GAMMA_T,TSTAR,NULLFORCE,UVEL,TNOW,TOLD,TNEW)
      CALL box_transport(RHO,UVEL)
      CALL box_density(TNOW,SNOW,RHO)

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_forward
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_final_state()
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_36
      INTEGER(w2f__i8) OpenAD_Symbol_37
      INTEGER(w2f__i8) OpenAD_Symbol_38
      INTEGER(w2f__i8) OpenAD_Symbol_39
      INTEGER(w2f__i8) OpenAD_Symbol_40
      INTEGER(w2f__i8) OpenAD_Symbol_41
      INTEGER(w2f__i8) OpenAD_Symbol_42
      INTEGER(w2f__i8) OpenAD_Symbol_43
      INTEGER(w2f__i8) OpenAD_Symbol_44
      INTEGER(w2f__i8) OpenAD_Symbol_45
      INTEGER(w2f__i8) OpenAD_Symbol_46
      INTEGER(w2f__i8) OpenAD_Symbol_47
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_vector(SNOW,size(SNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TNOW,size(TNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(TNOW,1),lbound(TNOW,1),-1
      TNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNOW,1),lbound(SNOW,1),-1
      SNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      DO L = 1, 6, 1
        TSVEC(INT(L)) = 0.0
      END DO
      DO L = 1, 3, 1
        TSVEC(INT(L)) = TNOW(L)%v
        TSVEC(L+3) = SNOW(L)%v
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_Symbol_40 = 0_w2f__i8
      DO L = 1,6,1
        TSVEC(INT(L)) = 0.0
        OpenAD_Symbol_40 = (INT(OpenAD_Symbol_40)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_40
      integer_tape_pointer = integer_tape_pointer+1
      OpenAD_Symbol_41 = 0_w2f__i8
      DO L = 1,3,1
        TSVEC(INT(L)) = TNOW(L)%v
        TSVEC(L+3) = SNOW(L)%v
        OpenAD_Symbol_41 = (INT(OpenAD_Symbol_41)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_41
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_36 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_37 = 1
      do while (INT(OpenAD_Symbol_37).LE.INT(OpenAD_Symbol_36))
        OpenAD_Symbol_37 = INT(OpenAD_Symbol_37)+1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_38 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_39 = 1
      do while (INT(OpenAD_Symbol_39).LE.INT(OpenAD_Symbol_38))
        OpenAD_Symbol_39 = INT(OpenAD_Symbol_39)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_final_state
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_ini_fields()
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_48
      INTEGER(w2f__i8) OpenAD_Symbol_49
      INTEGER(w2f__i8) OpenAD_Symbol_50
      INTEGER(w2f__i8) OpenAD_Symbol_51
      INTEGER(w2f__i8) OpenAD_Symbol_52
      INTEGER(w2f__i8) OpenAD_Symbol_53
      INTEGER(w2f__i8) OpenAD_Symbol_54
      INTEGER(w2f__i8) OpenAD_Symbol_55
      INTEGER(w2f__i8) OpenAD_Symbol_56
      INTEGER(w2f__i8) OpenAD_Symbol_57
      INTEGER(w2f__i8) OpenAD_Symbol_58
      INTEGER(w2f__i8) OpenAD_Symbol_59
      INTEGER(w2f__i8) OpenAD_Symbol_60
      INTEGER(w2f__i8) OpenAD_Symbol_61
      INTEGER(w2f__i8) OpenAD_Symbol_62
      INTEGER(w2f__i8) OpenAD_Symbol_63
      INTEGER(w2f__i8) OpenAD_Symbol_64
      INTEGER(w2f__i8) OpenAD_Symbol_65
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_178
      INTEGER(w2f__i4) OpenAD_Symbol_179
      INTEGER(w2f__i4) OpenAD_Symbol_180
      INTEGER(w2f__i4) OpenAD_Symbol_181
      INTEGER(w2f__i4) OpenAD_Symbol_182
      INTEGER(w2f__i4) OpenAD_Symbol_183
      INTEGER(w2f__i4) OpenAD_Symbol_66
      type(active) :: OpenAD_prp_12
      type(active) :: OpenAD_prp_13


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(HUNDRED,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(SV,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(UBAR,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_scalar(YEAR,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_p_real_vector(AREA,size(AREA),theArgFStack,theArgFSt
     +ackoffset,theArgFStackSize)
      call cp_store_p_real_vector(FW,size(FW),theArgFStack,theArgFStacko
     +ffset,theArgFStackSize)
      call cp_store_p_real_vector(NULLFORCE,size(NULLFORCE),theArgFStack
     +,theArgFStackoffset,theArgFStackSize)
      call cp_store_real_vector(S,size(S),theArgFStack,theArgFStackoffse
     +t,theArgFStackSize)
      call cp_store_real_vector(T,size(T),theArgFStack,theArgFStackoffse
     +t,theArgFStackSize)
      call cp_store_real_vector(XX,size(XX),theArgFStack,theArgFStackoff
     +set,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(XX,1),lbound(XX,1),-1
      XX(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(T,1),lbound(T,1),-1
      T(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(S,1),lbound(S,1),-1
      S(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(NULLFORCE,1),lbound(NULLFORCE,1),-1
      NULLFORCE(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FW,1),lbound(FW,1),-1
      FW(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(AREA,1),lbound(AREA,1),-1
      AREA(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      YEAR = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      UBAR = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      SV = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      HUNDRED = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      THC_TOT = 0.0D00
      THC_T = 0.0D00
      THC_S = 0.0D00
      METRIC1 = 0.0D00
      METRIC2 = 0.0D00
      METRIC = 0.0D00
      NULLFORCE(1) = 0.0D00
      NULLFORCE(2) = 0.0D00
      FW(1) = (AREA(1) *(HUNDRED / YEAR) * 3.5D+01)
      FW(2) = (- FW(1))
      TSTAR(1) = 2.2D+01
      TSTAR(2) = 0.0D00
      SSTAR(1) = 3.6D+01
      SSTAR(2) = 3.4D+01
      UBAR = (SV * 2.0D+01)
      T(1)%v = 2.0D+01
      T(2)%v = 1.0D00
      T(3)%v = 1.0D00
      S(1)%v = 3.55D+01
      S(2)%v = 3.45D+01
      S(3)%v = 3.45D+01
      DO L = 1,6,1
        TSVEC(INT(L)) = 0.0
      END DO
      DO L = 1,3,1
        T(INT(L))%v = (T(L)%v+XX(L)%v)
        S(INT(L))%v = (S(L)%v+XX(L+3)%v)
      END DO
      DO L = 1,3,1
        TNEW(INT(L))%v = T(L)%v
        SNEW(INT(L))%v = S(L)%v
        TOLD(INT(L))%v = T(L)%v
        SOLD(INT(L))%v = S(L)%v
        TNOW(INT(L))%v = T(L)%v
        SNOW(INT(L))%v = S(L)%v
      END DO
      UVEL%v = UBAR

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      THC_TOT = 0.0D00
      THC_T = 0.0D00
      THC_S = 0.0D00
      METRIC1 = 0.0D00
      METRIC2 = 0.0D00
      METRIC = 0.0D00
      NULLFORCE(1) = 0.0D00
      NULLFORCE(2) = 0.0D00
      FW(1) = (AREA(1)*(HUNDRED/YEAR)*3.5D+01)
      FW(2) = (-FW(1))
      TSTAR(1) = 2.2D+01
      TSTAR(2) = 0.0D00
      SSTAR(1) = 3.6D+01
      SSTAR(2) = 3.4D+01
      UBAR = (SV*2.0D+01)
      T(1)%v = 2.0D+01
      T(2)%v = 1.0D00
      T(3)%v = 1.0D00
      S(1)%v = 3.55D+01
      S(2)%v = 3.45D+01
      S(3)%v = 3.45D+01
      OpenAD_Symbol_54 = 0_w2f__i8
      DO L = 1,6,1
        TSVEC(INT(L)) = 0.0
        OpenAD_Symbol_54 = (INT(OpenAD_Symbol_54)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_54
      integer_tape_pointer = integer_tape_pointer+1
      OpenAD_Symbol_55 = 0_w2f__i8
      DO L = 1,3,1
        T(INT(L))%v = (T(L)%v+XX(L)%v)
        S(INT(L))%v = (S(L)%v+XX(L+3)%v)
        OpenAD_Symbol_66 = (L+3)
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_66
        integer_tape_pointer = integer_tape_pointer+1
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_55 = (INT(OpenAD_Symbol_55)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_55
      integer_tape_pointer = integer_tape_pointer+1
      OpenAD_Symbol_56 = 0_w2f__i8
      DO L = 1,3,1
        TNEW(INT(L))%v = T(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        SNEW(INT(L))%v = S(L)%v
        TOLD(INT(L))%v = T(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        SOLD(INT(L))%v = S(L)%v
        TNOW(INT(L))%v = T(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        SNOW(INT(L))%v = S(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_56 = (INT(OpenAD_Symbol_56)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_56
      integer_tape_pointer = integer_tape_pointer+1
      UVEL%v = UBAR

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      UVEL%d = 0.0d0
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_48 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_49 = 1
      do while (INT(OpenAD_Symbol_49).LE.INT(OpenAD_Symbol_48))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_180 = integer_tape(integer_tape_pointer)
        S(OpenAD_Symbol_180)%d = S(OpenAD_Symbol_180)%d+SNOW(OpenAD_Symb
     +ol_180)%d
        SNOW(OpenAD_Symbol_180)%d = 0.0d0
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_181 = integer_tape(integer_tape_pointer)
        T(OpenAD_Symbol_181)%d = T(OpenAD_Symbol_181)%d+TNOW(OpenAD_Symb
     +ol_181)%d
        TNOW(OpenAD_Symbol_181)%d = 0.0d0
        S(OpenAD_Symbol_181)%d = S(OpenAD_Symbol_181)%d+SOLD(OpenAD_Symb
     +ol_181)%d
        SOLD(OpenAD_Symbol_181)%d = 0.0d0
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_182 = integer_tape(integer_tape_pointer)
        T(OpenAD_Symbol_182)%d = T(OpenAD_Symbol_182)%d+TOLD(OpenAD_Symb
     +ol_182)%d
        TOLD(OpenAD_Symbol_182)%d = 0.0d0
        S(OpenAD_Symbol_182)%d = S(OpenAD_Symbol_182)%d+SNEW(OpenAD_Symb
     +ol_182)%d
        SNEW(OpenAD_Symbol_182)%d = 0.0d0
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_183 = integer_tape(integer_tape_pointer)
        T(OpenAD_Symbol_183)%d = T(OpenAD_Symbol_183)%d+TNEW(OpenAD_Symb
     +ol_183)%d
        TNEW(OpenAD_Symbol_183)%d = 0.0d0
        OpenAD_Symbol_49 = INT(OpenAD_Symbol_49)+1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_50 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_51 = 1
      do while (INT(OpenAD_Symbol_51).LE.INT(OpenAD_Symbol_50))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_178 = integer_tape(integer_tape_pointer)
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_179 = integer_tape(integer_tape_pointer)
        XX(OpenAD_Symbol_179)%d = XX(OpenAD_Symbol_179)%d+S(OpenAD_Symbo
     +l_178)%d
        OpenAD_prp_13%d = OpenAD_prp_13%d+S(OpenAD_Symbol_178)%d
        S(OpenAD_Symbol_178)%d = 0.0d0
        XX(OpenAD_Symbol_178)%d = XX(OpenAD_Symbol_178)%d+T(OpenAD_Symbo
     +l_178)%d
        OpenAD_prp_12%d = OpenAD_prp_12%d+T(OpenAD_Symbol_178)%d
        T(OpenAD_Symbol_178)%d = 0.0d0
        S(OpenAD_Symbol_178)%d = S(OpenAD_Symbol_178)%d+OpenAD_prp_13%d
        OpenAD_prp_13%d = 0.0d0
        T(OpenAD_Symbol_178)%d = T(OpenAD_Symbol_178)%d+OpenAD_prp_12%d
        OpenAD_prp_12%d = 0.0d0
        OpenAD_Symbol_51 = INT(OpenAD_Symbol_51)+1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_52 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_53 = 1
      do while (INT(OpenAD_Symbol_53).LE.INT(OpenAD_Symbol_52))
        OpenAD_Symbol_53 = INT(OpenAD_Symbol_53)+1
      END DO
      S(3)%d = 0.0d0
      S(2)%d = 0.0d0
      S(1)%d = 0.0d0
      T(3)%d = 0.0d0
      T(2)%d = 0.0d0
      T(1)%d = 0.0d0

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_ini_fields
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_ini_params()
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_100
      INTEGER(w2f__i8) OpenAD_Symbol_101
      INTEGER(w2f__i8) OpenAD_Symbol_102
      INTEGER(w2f__i8) OpenAD_Symbol_103
      INTEGER(w2f__i8) OpenAD_Symbol_104
      INTEGER(w2f__i8) OpenAD_Symbol_105
      INTEGER(w2f__i8) OpenAD_Symbol_106
      INTEGER(w2f__i8) OpenAD_Symbol_107
      INTEGER(w2f__i8) OpenAD_Symbol_108
      INTEGER(w2f__i8) OpenAD_Symbol_109
      INTEGER(w2f__i8) OpenAD_Symbol_110
      INTEGER(w2f__i8) OpenAD_Symbol_111
      INTEGER(w2f__i8) OpenAD_Symbol_112
      INTEGER(w2f__i8) OpenAD_Symbol_113
      INTEGER(w2f__i8) OpenAD_Symbol_114
      INTEGER(w2f__i8) OpenAD_Symbol_67
      INTEGER(w2f__i8) OpenAD_Symbol_68
      INTEGER(w2f__i8) OpenAD_Symbol_69
      INTEGER(w2f__i8) OpenAD_Symbol_70
      INTEGER(w2f__i8) OpenAD_Symbol_71
      INTEGER(w2f__i8) OpenAD_Symbol_72
      INTEGER(w2f__i8) OpenAD_Symbol_73
      INTEGER(w2f__i8) OpenAD_Symbol_74
      INTEGER(w2f__i8) OpenAD_Symbol_75
      INTEGER(w2f__i8) OpenAD_Symbol_76
      INTEGER(w2f__i8) OpenAD_Symbol_77
      INTEGER(w2f__i8) OpenAD_Symbol_78
      INTEGER(w2f__i8) OpenAD_Symbol_79
      INTEGER(w2f__i8) OpenAD_Symbol_80
      INTEGER(w2f__i8) OpenAD_Symbol_81
      INTEGER(w2f__i8) OpenAD_Symbol_82
      INTEGER(w2f__i8) OpenAD_Symbol_83
      INTEGER(w2f__i8) OpenAD_Symbol_84
      INTEGER(w2f__i8) OpenAD_Symbol_85
      INTEGER(w2f__i8) OpenAD_Symbol_86
      INTEGER(w2f__i8) OpenAD_Symbol_87
      INTEGER(w2f__i8) OpenAD_Symbol_88
      INTEGER(w2f__i8) OpenAD_Symbol_89
      INTEGER(w2f__i8) OpenAD_Symbol_90
      INTEGER(w2f__i8) OpenAD_Symbol_91
      INTEGER(w2f__i8) OpenAD_Symbol_92
      INTEGER(w2f__i8) OpenAD_Symbol_93
      INTEGER(w2f__i8) OpenAD_Symbol_94
      INTEGER(w2f__i8) OpenAD_Symbol_95
      INTEGER(w2f__i8) OpenAD_Symbol_96
      INTEGER(w2f__i8) OpenAD_Symbol_97
      INTEGER(w2f__i8) OpenAD_Symbol_98
      INTEGER(w2f__i8) OpenAD_Symbol_99
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) I
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) J
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(ALPHA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(BETA,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_scalar(BWIDTH,theArgFStack,theArgFStackoffset,t
     +heArgFStackSize)
      call cp_store_real_scalar(DAY,theArgFStack,theArgFStackoffset,theA
     +rgFStackSize)
      call cp_store_real_scalar(DAYS_PER_50M_MIXED_LAYER,theArgFStack,th
     +eArgFStackoffset,theArgFStackSize)
      call cp_store_real_scalar(DELTA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(DELTA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(EPSILON_REGULARIZE,theArgFStack,theArgFS
     +tackoffset,theArgFStackSize)
      call cp_store_real_scalar(INTEGRATION_TIME,theArgFStack,theArgFSta
     +ckoffset,theArgFStackSize)
      call cp_store_real_scalar(SV,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(THOUSAND,theArgFStack,theArgFStackoffset
     +,theArgFStackSize)
      call cp_store_real_scalar(U0,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(YEAR,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_p_real_vector(AREA,size(AREA),theArgFStack,theArgFSt
     +ackoffset,theArgFStackSize)
      call cp_store_p_real_vector(BHEIGHT,size(BHEIGHT),theArgFStack,the
     +ArgFStackoffset,theArgFStackSize)
      call cp_store_p_real_vector(BLENGTH,size(BLENGTH),theArgFStack,the
     +ArgFStackoffset,theArgFStackSize)
      call cp_store_p_real_vector(PROJ_S,size(PROJ_S),theArgFStack,theAr
     +gFStackoffset,theArgFStackSize)
      call cp_store_p_real_vector(PROJ_T,size(PROJ_T),theArgFStack,theAr
     +gFStackoffset,theArgFStackSize)
      call cp_store_p_real_vector(R,size(R),theArgFStack,theArgFStackoff
     +set,theArgFStackSize)
      do cp_loop_variable_2 = lbound(X,2),ubound(X,2)
      call cp_store_p_real_vector(X(:,cp_loop_variable_2),size(X(:,cp_lo
     +op_variable_2)),theArgFStack,theArgFStackoffset,theArgFStackSize)
      end do
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_2 = ubound(X,2),lbound(X,2),-1
      do cp_loop_variable_1 = ubound(X,1),lbound(X,1),-1
      X(cp_loop_variable_1,cp_loop_variable_2) = theArgFStack(theArgFSta
     +ckoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      end do
      do cp_loop_variable_1 = ubound(R,1),lbound(R,1),-1
      R(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(PROJ_T,1),lbound(PROJ_T,1),-1
      PROJ_T(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(PROJ_S,1),lbound(PROJ_S,1),-1
      PROJ_S(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(BLENGTH,1),lbound(BLENGTH,1),-1
      BLENGTH(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(BHEIGHT,1),lbound(BHEIGHT,1),-1
      BHEIGHT(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(AREA,1),lbound(AREA,1),-1
      AREA(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      YEAR = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      U0 = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      THOUSAND = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      SV = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      INTEGRATION_TIME = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      EPSILON_REGULARIZE = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DAYS_PER_50M_MIXED_LAYER = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DAY = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      BWIDTH = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      BETA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ALPHA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      VERBMODE = .FALSE.
      BLENGTH(1) = 5.0D+08
      BLENGTH(2) = 1.0D+08
      BLENGTH(3) = BLENGTH(1)
      BHEIGHT(1) = 1.0D+05
      BHEIGHT(3) = 4.0D+05
      BHEIGHT(2) = (BHEIGHT(1) + BHEIGHT(3))
      DELTA = (BHEIGHT(1) /(BHEIGHT(1) + BHEIGHT(3)))
      BWIDTH = 4.0D+08
      AREA(1) = (BLENGTH(1) * BWIDTH)
      AREA(2) = (BLENGTH(2) * BWIDTH)
      AREA(3) = (BLENGTH(3) * BWIDTH)
      VOL(1) = (AREA(1) * BHEIGHT(1))
      VOL(2) = (AREA(2) *(BHEIGHT(1) + BHEIGHT(3)))
      VOL(3) = (AREA(3) * BHEIGHT(3))
      ROBERT_FILTER_COEFF = 2.5D-01
      HUNDRED = 1.0D+02
      THOUSAND = 1.0D+03
      DAY = 8.64D+04
      YEAR = (DAY * 3.65D+02)
      SV = 1.0D+12
      U0 = ((SV * 1.6D+01) / 4.00000000000000019169D-04)
      ALPHA = 1.6679999999999998864D-04
      BETA = 7.81000000000000010186D-04
      DAYS_PER_50M_MIXED_LAYER = 5.0D+01
      GAMMA_T = (1.0D00 /(DAY * 3.0D+02))
      GAMMA_S = (0.0D00 /((BHEIGHT(1) / 5.0D+03) * DAY * DAYS_PER_50M_MI
     +XED_LAYER))
      EPSILON_IC = (-1.00000000000000004792D-04)
      NOISE_CORRELATION_TIME = (DAY * 1.5D+01)
      DELTA_T = (DAY * 5.0D00)
      INTEGRATION_TIME = (YEAR * 5.0D+01)
      N_MAX = INT(INTEGRATION_TIME / DELTA_T)
      FDEPS = 9.99999999999999954748D-07
      Y(1) = (THOUSAND / 3.2680000000000000715D-02)
      Y(2) = (THOUSAND / 7.9399999999999991418D-03)
      Y(3) = (THOUSAND / 1.39999999999999998578D-03)
      Y(4) = (THOUSAND / 1.41699999999999992628D-01)
      Y(5) = (THOUSAND / 1.28599999999999992095D-01)
      Y(6) = (THOUSAND / 8.7800000000000003042D-02)
      R(1) = (ALPHA * DELTA)
      R(2) = (- ALPHA)
      R(3) = (ALPHA *(1.0D00 - DELTA))
      R(4) = (-(BETA * DELTA))
      R(5) = BETA
      R(6) = (-(BETA *(1.0D00 - DELTA)))
      DO L = 1, 6, 1
        R(INT(L)) = ((R(L) * U0) / SV)
      END DO
      DO L = 1, 6, 1
        IF(L .LE. 3) THEN
          PROJ_T(INT(L)) = 1.0D00
          PROJ_S(INT(L)) = 0.0D00
        ELSE
          PROJ_T(INT(L)) = 0.0D00
          PROJ_S(INT(L)) = 1.0D00
        ENDIF
      END DO
      DO L = 1, 6, 1
        R_T(INT(L)) = (PROJ_T(L) * R(L))
        R_S(INT(L)) = (PROJ_S(L) * R(L))
      END DO
      R1(1) = 1.0D00
      R1(2) = (-1.0D00)
      R1(3) = 0.0D00
      R1(4) = 0.0D00
      R1(5) = 0.0D00
      R1(6) = 0.0D00
      DO J = 1, 6, 1
        DO I = 1, 6, 1
          X(INT(I), INT(J)) = (R(I) * R(J))
        END DO
      END DO
      EPSILON_REGULARIZE = 1.00000000000000002092D-08
      DO J = 1, 6, 1
        DO I = 1, 6, 1
          X(INT(I), INT(J)) = (X(I, J) + EPSILON_REGULARIZE)
        END DO
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      VERBMODE = .FALSE.
      BLENGTH(1) = 5.0D+08
      BLENGTH(2) = 1.0D+08
      BLENGTH(3) = BLENGTH(1)
      BHEIGHT(1) = 1.0D+05
      BHEIGHT(3) = 4.0D+05
      BHEIGHT(2) = (BHEIGHT(1) + BHEIGHT(3))
      DELTA = (BHEIGHT(1) /(BHEIGHT(1) + BHEIGHT(3)))
      BWIDTH = 4.0D+08
      AREA(1) = (BLENGTH(1) * BWIDTH)
      AREA(2) = (BLENGTH(2) * BWIDTH)
      AREA(3) = (BLENGTH(3) * BWIDTH)
      VOL(1) = (AREA(1) * BHEIGHT(1))
      VOL(2) = (AREA(2) *(BHEIGHT(1) + BHEIGHT(3)))
      VOL(3) = (AREA(3) * BHEIGHT(3))
      ROBERT_FILTER_COEFF = 2.5D-01
      HUNDRED = 1.0D+02
      THOUSAND = 1.0D+03
      DAY = 8.64D+04
      YEAR = (DAY * 3.65D+02)
      SV = 1.0D+12
      U0 = ((SV * 1.6D+01) / 4.00000000000000019169D-04)
      ALPHA = 1.6679999999999998864D-04
      BETA = 7.81000000000000010186D-04
      DAYS_PER_50M_MIXED_LAYER = 5.0D+01
      GAMMA_T = (1.0D00 /(DAY * 3.0D+02))
      GAMMA_S = (0.0D00 /((BHEIGHT(1) / 5.0D+03) * DAY * DAYS_PER_50M_MI
     +XED_LAYER))
      EPSILON_IC = (-1.00000000000000004792D-04)
      NOISE_CORRELATION_TIME = (DAY * 1.5D+01)
      DELTA_T = (DAY * 5.0D00)
      INTEGRATION_TIME = (YEAR * 5.0D+01)
      N_MAX = INT(INTEGRATION_TIME / DELTA_T)
      FDEPS = 9.99999999999999954748D-07
      Y(1) = (THOUSAND / 3.2680000000000000715D-02)
      Y(2) = (THOUSAND / 7.9399999999999991418D-03)
      Y(3) = (THOUSAND / 1.39999999999999998578D-03)
      Y(4) = (THOUSAND / 1.41699999999999992628D-01)
      Y(5) = (THOUSAND / 1.28599999999999992095D-01)
      Y(6) = (THOUSAND / 8.7800000000000003042D-02)
      R(1) = (ALPHA * DELTA)
      R(2) = (- ALPHA)
      R(3) = (ALPHA *(1.0D00 - DELTA))
      R(4) = (-(BETA * DELTA))
      R(5) = BETA
      R(6) = (-(BETA *(1.0D00 - DELTA)))
      OpenAD_Symbol_82 = 0_w2f__i8
      DO L = 1, 6, 1
        R(INT(L)) = ((R(L) * U0) / SV)
        OpenAD_Symbol_82 = (INT(OpenAD_Symbol_82) + INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_82
      integer_tape_pointer = integer_tape_pointer+1
      OpenAD_Symbol_83 = 0_w2f__i8
      DO L = 1, 6, 1
        IF(L .LE. 3) THEN
          PROJ_T(INT(L)) = 1.0D00
          PROJ_S(INT(L)) = 0.0D00
          OpenAD_Symbol_84 = 1_w2f__i8
          integer_tape(integer_tape_pointer) = OpenAD_Symbol_84
          integer_tape_pointer = integer_tape_pointer+1
        ELSE
          PROJ_T(INT(L)) = 0.0D00
          PROJ_S(INT(L)) = 1.0D00
          OpenAD_Symbol_85 = 0_w2f__i8
          integer_tape(integer_tape_pointer) = OpenAD_Symbol_85
          integer_tape_pointer = integer_tape_pointer+1
        ENDIF
        OpenAD_Symbol_83 = (INT(OpenAD_Symbol_83) + INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_83
      integer_tape_pointer = integer_tape_pointer+1
      OpenAD_Symbol_86 = 0_w2f__i8
      DO L = 1, 6, 1
        R_T(INT(L)) = (PROJ_T(L) * R(L))
        R_S(INT(L)) = (PROJ_S(L) * R(L))
        OpenAD_Symbol_86 = (INT(OpenAD_Symbol_86) + INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_86
      integer_tape_pointer = integer_tape_pointer+1
      R1(1) = 1.0D00
      R1(2) = (-1.0D00)
      R1(3) = 0.0D00
      R1(4) = 0.0D00
      R1(5) = 0.0D00
      R1(6) = 0.0D00
      OpenAD_Symbol_87 = 0_w2f__i8
      DO J = 1, 6, 1
        OpenAD_Symbol_88 = 0_w2f__i8
        DO I = 1, 6, 1
          X(INT(I), INT(J)) = (R(I) * R(J))
          OpenAD_Symbol_88 = (INT(OpenAD_Symbol_88) + INT(1_w2f__i8))
        END DO
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_88
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_87 = (INT(OpenAD_Symbol_87) + INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_87
      integer_tape_pointer = integer_tape_pointer+1
      EPSILON_REGULARIZE = 1.00000000000000002092D-08
      OpenAD_Symbol_89 = 0_w2f__i8
      DO J = 1, 6, 1
        OpenAD_Symbol_90 = 0_w2f__i8
        DO I = 1, 6, 1
          X(INT(I), INT(J)) = (X(I, J) + EPSILON_REGULARIZE)
          OpenAD_Symbol_90 = (INT(OpenAD_Symbol_90) + INT(1_w2f__i8))
        END DO
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_90
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_89 = (INT(OpenAD_Symbol_89) + INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_89
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_67 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_68 = 1
      DO WHILE(INT(OpenAD_Symbol_68) .LE. INT(OpenAD_Symbol_67))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_69 = integer_tape(integer_tape_pointer)
        OpenAD_Symbol_70 = 1
        DO WHILE(INT(OpenAD_Symbol_70) .LE. INT(OpenAD_Symbol_69))
          OpenAD_Symbol_70 = INT(OpenAD_Symbol_70) + 1
        END DO
        OpenAD_Symbol_68 = INT(OpenAD_Symbol_68) + 1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_71 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_72 = 1
      DO WHILE(INT(OpenAD_Symbol_72) .LE. INT(OpenAD_Symbol_71))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_73 = integer_tape(integer_tape_pointer)
        OpenAD_Symbol_74 = 1
        DO WHILE(INT(OpenAD_Symbol_74) .LE. INT(OpenAD_Symbol_73))
          OpenAD_Symbol_74 = INT(OpenAD_Symbol_74) + 1
        END DO
        OpenAD_Symbol_72 = INT(OpenAD_Symbol_72) + 1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_75 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_76 = 1
      DO WHILE(INT(OpenAD_Symbol_76) .LE. INT(OpenAD_Symbol_75))
        OpenAD_Symbol_76 = INT(OpenAD_Symbol_76) + 1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_77 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_78 = 1
      DO WHILE(INT(OpenAD_Symbol_78) .LE. INT(OpenAD_Symbol_77))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_79 = integer_tape(integer_tape_pointer)
        IF(OpenAD_Symbol_79 .ne. 0) THEN
        ENDIF
        OpenAD_Symbol_78 = INT(OpenAD_Symbol_78) + 1
      END DO
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_80 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_81 = 1
      DO WHILE(INT(OpenAD_Symbol_81) .LE. INT(OpenAD_Symbol_80))
        OpenAD_Symbol_81 = INT(OpenAD_Symbol_81) + 1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_ini_params
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_model_body()
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_115
      INTEGER(w2f__i8) OpenAD_Symbol_116
      INTEGER(w2f__i8) OpenAD_Symbol_117
      INTEGER(w2f__i8) OpenAD_Symbol_118
      INTEGER(w2f__i8) OpenAD_Symbol_119
      INTEGER(w2f__i8) OpenAD_Symbol_120
      INTEGER(w2f__i8) OpenAD_Symbol_121
      INTEGER(w2f__i8) OpenAD_Symbol_122
      INTEGER(w2f__i8) OpenAD_Symbol_123
      INTEGER(w2f__i8) OpenAD_Symbol_124
      INTEGER(w2f__i8) OpenAD_Symbol_125
      INTEGER(w2f__i8) OpenAD_Symbol_126
      INTEGER(w2f__i8) OpenAD_Symbol_127
      INTEGER(w2f__i8) OpenAD_Symbol_128
      INTEGER(w2f__i8) OpenAD_Symbol_129
      INTEGER(w2f__i8) OpenAD_Symbol_130
      INTEGER(w2f__i8) OpenAD_Symbol_131
      INTEGER(w2f__i8) OpenAD_Symbol_132
      INTEGER(w2f__i8) OpenAD_Symbol_133
      INTEGER(w2f__i8) OpenAD_Symbol_134
      INTEGER(w2f__i8) OpenAD_Symbol_135
      INTEGER(w2f__i8) OpenAD_Symbol_136
      INTEGER(w2f__i8) OpenAD_Symbol_137
      INTEGER(w2f__i8) OpenAD_Symbol_138
      INTEGER(w2f__i8) OpenAD_Symbol_139
      INTEGER(w2f__i8) OpenAD_Symbol_140
      INTEGER(w2f__i8) OpenAD_Symbol_141
      INTEGER(w2f__i8) OpenAD_Symbol_142
      INTEGER(w2f__i8) OpenAD_Symbol_143
      INTEGER(w2f__i8) OpenAD_Symbol_144
C
C     **** Local Variables and Functions ****
C
      EXTERNAL box_final_state
      EXTERNAL box_forward
      EXTERNAL box_ini_fields
      INTEGER(w2f__i4) ILEV1
      INTEGER(w2f__i4) ILEV2
      INTEGER(w2f__i4) ILOOP
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) MAXLEV2
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Top Level Pragmas ****
C
C$OPENAD INDEPENDENT(XX)
C$OPENAD DEPENDENT(TNEW)
C$OPENAD DEPENDENT(SNEW)
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(ALPHA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(BETA,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_scalar(DELTA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(DELTA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(GAMMA_S,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(GAMMA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(HUNDRED,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_int_scalar(N_MAX,theArgIStack,theArgIStackoffset,the
     +ArgIStackSize)
      call cp_store_real_scalar(ROBERT_FILTER_COEFF,theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_scalar(SV,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(U0,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_scalar(UBAR,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_scalar(UVEL%v,theArgFStack,theArgFStackoffset,t
     +heArgFStackSize)
      call cp_store_real_scalar(YEAR,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_p_real_vector(AREA,size(AREA),theArgFStack,theArgFSt
     +ackoffset,theArgFStackSize)
      call cp_store_p_real_vector(FW,size(FW),theArgFStack,theArgFStacko
     +ffset,theArgFStackSize)
      call cp_store_p_real_vector(NULLFORCE,size(NULLFORCE),theArgFStack
     +,theArgFStackoffset,theArgFStackSize)
      call cp_store_real_vector(RHO,size(RHO),theArgFStack,theArgFStacko
     +ffset,theArgFStackSize)
      call cp_store_real_vector(S,size(S),theArgFStack,theArgFStackoffse
     +t,theArgFStackSize)
      call cp_store_real_vector(SNEW,size(SNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SNOW,size(SNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SOLD,size(SOLD),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_p_real_vector(SSTAR,size(SSTAR),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(T,size(T),theArgFStack,theArgFStackoffse
     +t,theArgFStackSize)
      call cp_store_real_vector(TNEW,size(TNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TNOW,size(TNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TOLD,size(TOLD),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_p_real_vector(TSTAR,size(TSTAR),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_p_real_vector(VOL,size(VOL),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(XX,size(XX),theArgFStack,theArgFStackoff
     +set,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(XX,1),lbound(XX,1),-1
      XX(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(VOL,1),lbound(VOL,1),-1
      VOL(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TSTAR,1),lbound(TSTAR,1),-1
      TSTAR(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TOLD,1),lbound(TOLD,1),-1
      TOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TNOW,1),lbound(TNOW,1),-1
      TNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TNEW,1),lbound(TNEW,1),-1
      TNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(T,1),lbound(T,1),-1
      T(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SSTAR,1),lbound(SSTAR,1),-1
      SSTAR(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SOLD,1),lbound(SOLD,1),-1
      SOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNOW,1),lbound(SNOW,1),-1
      SNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNEW,1),lbound(SNEW,1),-1
      SNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(S,1),lbound(S,1),-1
      S(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(RHO,1),lbound(RHO,1),-1
      RHO(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(NULLFORCE,1),lbound(NULLFORCE,1),-1
      NULLFORCE(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FW,1),lbound(FW,1),-1
      FW(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(AREA,1),lbound(AREA,1),-1
      AREA(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      YEAR = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      UVEL%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      UBAR = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      U0 = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      SV = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ROBERT_FILTER_COEFF = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      N_MAX = theArgIStack(theArgIStackoffset)
      theArgIStackoffset = theArgIStackoffset-1
      HUNDRED = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      GAMMA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      GAMMA_S = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      BETA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ALPHA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      CALL box_ini_fields()
      MAXLEV2 = ((N_MAX / 73) + 1)
      IF(N_MAX .GT. 3650) THEN
        WRITE(*,*) 'NEED TO SET nlev1*nlev2 >= n_max '
      ELSE
        DO ILEV2 = 1, 50, 1
          IF(ILEV2 .LE. MAXLEV2) THEN
            DO ILEV1 = 1, 73, 1
              ILOOP = (ILEV1 + ILEV2 * 73 +(-73))
              IF(ILOOP .LE. N_MAX) THEN
                CALL box_forward(ILEV1)
              ENDIF
            END DO
          ENDIF
        END DO
        CALL box_final_state()
      ENDIF

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      CALL box_ini_fields()
      MAXLEV2 = ((N_MAX / 73) + 1)
      IF(N_MAX .GT. 3650) THEN
        WRITE(*,*) 'NEED TO SET nlev1*nlev2 >= n_max '
        OpenAD_Symbol_128 = 1_w2f__i8
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_128
        integer_tape_pointer = integer_tape_pointer+1
      ELSE
        OpenAD_Symbol_122 = 0_w2f__i8
        DO ILEV2 = 1, 50, 1
          IF(ILEV2 .LE. MAXLEV2) THEN
            OpenAD_Symbol_123 = 0_w2f__i8
            DO ILEV1 = 1, 73, 1
              ILOOP = (ILEV1 + ILEV2 * 73 +(-73))
              IF(ILOOP .LE. N_MAX) THEN
                CALL box_forward(ILEV1)
                OpenAD_Symbol_124 = 1_w2f__i8
                integer_tape(integer_tape_pointer) = OpenAD_Symbol_124
                integer_tape_pointer = integer_tape_pointer+1
              ELSE
                OpenAD_Symbol_125 = 0_w2f__i8
                integer_tape(integer_tape_pointer) = OpenAD_Symbol_125
                integer_tape_pointer = integer_tape_pointer+1
              ENDIF
              OpenAD_Symbol_123 = (INT(OpenAD_Symbol_123) + INT( 1_w2f__
     +i8))
            END DO
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_123
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_127 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_127
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            OpenAD_Symbol_126 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_126
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          OpenAD_Symbol_122 = (INT(OpenAD_Symbol_122) + INT(1_w2f__i8))
        END DO
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_122
        integer_tape_pointer = integer_tape_pointer+1
        CALL box_final_state()
        OpenAD_Symbol_129 = 0_w2f__i8
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_129
        integer_tape_pointer = integer_tape_pointer+1
      ENDIF

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_115 = integer_tape(integer_tape_pointer)
      IF(OpenAD_Symbol_115 .ne. 0) THEN
      ELSE
        CALL box_final_state()
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_116 = integer_tape(integer_tape_pointer)
        OpenAD_Symbol_117 = 1
        DO WHILE(INT(OpenAD_Symbol_117) .LE. INT(OpenAD_Symbol_116))
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_118 = integer_tape(integer_tape_pointer)
          IF(OpenAD_Symbol_118 .ne. 0) THEN
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_119 = integer_tape(integer_tape_pointer)
            OpenAD_Symbol_120 = 1
            DO WHILE(INT(OpenAD_Symbol_120) .LE. INT(OpenAD_Symbol_119) 
     +)
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_121 = integer_tape(integer_tape_pointer)
              IF(OpenAD_Symbol_121 .ne. 0) THEN
                CALL box_forward(ILEV1)
              ENDIF
              OpenAD_Symbol_120 = INT(OpenAD_Symbol_120) + 1
            END DO
          ENDIF
          OpenAD_Symbol_117 = INT(OpenAD_Symbol_117) + 1
        END DO
      ENDIF
      CALL box_ini_fields()

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_model_body
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_density(TLOC, SLOC, RHOLOC)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_12
      INTEGER(w2f__i8) OpenAD_Symbol_13
      INTEGER(w2f__i8) OpenAD_Symbol_14
      INTEGER(w2f__i8) OpenAD_Symbol_15
      INTEGER(w2f__i8) OpenAD_Symbol_16
      INTEGER(w2f__i8) OpenAD_Symbol_17
C
C     **** Parameters and Result ****
C
      type(active) :: TLOC(1:3)
      type(active) :: SLOC(1:3)
      type(active) :: RHOLOC(1:3)
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_152
      REAL(w2f__8) OpenAD_Symbol_153
      REAL(w2f__8) OpenAD_Symbol_154
      REAL(w2f__8) OpenAD_acc_0
      REAL(w2f__8) OpenAD_lin_0
      REAL(w2f__8) OpenAD_lin_1


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(ALPHA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(BETA,theArgFStack,theArgFStackoffset,the
     +ArgFStackSize)
      call cp_store_real_vector(TLOC,size(TLOC),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SLOC,size(SLOC),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(SLOC,1),lbound(SLOC,1),-1
      SLOC(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TLOC,1),lbound(TLOC,1),-1
      TLOC(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      BETA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      ALPHA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      DO L = 1, 3, 1
        RHOLOC(INT(L))%v = (SLOC(L)%v*BETA-TLOC(L)%v*ALPHA)
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_Symbol_14 = 0_w2f__i8
      DO L = 1,3,1
        OpenAD_lin_0 = BETA
        OpenAD_lin_1 = ALPHA
        RHOLOC(INT(L))%v = (SLOC(L)%v*BETA-TLOC(L)%v*ALPHA)
        OpenAD_acc_0 = (OpenAD_lin_1*INT((-1_w2f__i8)))
        double_tape(double_tape_pointer) = OpenAD_lin_0
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_0
        double_tape_pointer = double_tape_pointer+1
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_14 = (INT(OpenAD_Symbol_14)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_14
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_12 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_13 = 1
      do while (INT(OpenAD_Symbol_13).LE.INT(OpenAD_Symbol_12))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_152 = integer_tape(integer_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_153 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_154 = double_tape(double_tape_pointer)
        TLOC(OpenAD_Symbol_152)%d = TLOC(OpenAD_Symbol_152)%d+RHOLOC(Ope
     +nAD_Symbol_152)%d*(OpenAD_Symbol_153)
        SLOC(OpenAD_Symbol_152)%d = SLOC(OpenAD_Symbol_152)%d+RHOLOC(Ope
     +nAD_Symbol_152)%d*(OpenAD_Symbol_154)
        RHOLOC(OpenAD_Symbol_152)%d = 0.0d0
        OpenAD_Symbol_13 = INT(OpenAD_Symbol_13)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_density
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_transport(RHOLOC, UVELLOC)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Parameters and Result ****
C
      type(active) :: RHOLOC(1:3)
      type(active) :: UVELLOC
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      REAL(w2f__8) OpenAD_Symbol_155
      REAL(w2f__8) OpenAD_Symbol_156
      REAL(w2f__8) OpenAD_Symbol_157
      REAL(w2f__8) OpenAD_acc_1
      REAL(w2f__8) OpenAD_aux_0
      REAL(w2f__8) OpenAD_aux_1
      REAL(w2f__8) OpenAD_lin_2
      REAL(w2f__8) OpenAD_lin_3
      REAL(w2f__8) OpenAD_lin_4
      type(active) :: OpenAD_prp_0
C
C     **** Statements ****
C


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C$OPENAD XXX Template ad_template.f

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(DELTA,theArgFStack,theArgFStackoffset,th
     +eArgFStackSize)
      call cp_store_real_scalar(U0,theArgFStack,theArgFStackoffset,theAr
     +gFStackSize)
      call cp_store_real_vector(RHOLOC,size(RHOLOC),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(RHOLOC,1),lbound(RHOLOC,1),-1
      RHOLOC(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      U0 = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
      UVELLOC%v = (-(U0*(RHOLOC(1)%v*DELTA+RHOLOC(3)%v*(1.0D00-DELTA)-RH
     +OLOC(2)%v)))

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_aux_1 = (1.0D00-DELTA)
      OpenAD_aux_0 = (RHOLOC(1)%v*DELTA+RHOLOC(3)%v*OpenAD_aux_1-RHOLOC(
     +2)%v)
      OpenAD_lin_3 = DELTA
      OpenAD_lin_4 = OpenAD_aux_1
      OpenAD_lin_2 = U0
      UVELLOC%v = (-(U0*OpenAD_aux_0))
      OpenAD_acc_1 = (OpenAD_lin_2*INT((-1_w2f__i8)))
      double_tape(double_tape_pointer) = OpenAD_lin_3
      double_tape_pointer = double_tape_pointer+1
      double_tape(double_tape_pointer) = OpenAD_lin_4
      double_tape_pointer = double_tape_pointer+1
      double_tape(double_tape_pointer) = OpenAD_acc_1
      double_tape_pointer = double_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      double_tape_pointer = double_tape_pointer-1
      OpenAD_Symbol_155 = double_tape(double_tape_pointer)
      double_tape_pointer = double_tape_pointer-1
      OpenAD_Symbol_156 = double_tape(double_tape_pointer)
      double_tape_pointer = double_tape_pointer-1
      OpenAD_Symbol_157 = double_tape(double_tape_pointer)
      OpenAD_prp_0%d = OpenAD_prp_0%d+UVELLOC%d*(OpenAD_Symbol_155)
      UVELLOC%d = 0.0d0
      RHOLOC(3)%d = RHOLOC(3)%d+OpenAD_prp_0%d*(OpenAD_Symbol_156)
      RHOLOC(1)%d = RHOLOC(1)%d+OpenAD_prp_0%d*(OpenAD_Symbol_157)
      RHOLOC(2)%d = RHOLOC(2)%d-OpenAD_prp_0%d
      OpenAD_prp_0%d = 0.0d0

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_transport
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_robert_filter(FLDNOW, FLDOLD, FLDNEW)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_24
      INTEGER(w2f__i8) OpenAD_Symbol_25
      INTEGER(w2f__i8) OpenAD_Symbol_26
      INTEGER(w2f__i8) OpenAD_Symbol_27
      INTEGER(w2f__i8) OpenAD_Symbol_28
      INTEGER(w2f__i8) OpenAD_Symbol_29
C
C     **** Parameters and Result ****
C
      type(active) :: FLDNOW(1:3)
      type(active) :: FLDOLD(1:3)
      type(active) :: FLDNEW(1:3)
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_174
      REAL(w2f__8) OpenAD_Symbol_175
      REAL(w2f__8) OpenAD_aux_22
      REAL(w2f__8) OpenAD_lin_31
      type(active) :: OpenAD_prp_7
      type(active) :: OpenAD_prp_8
      type(active) :: OpenAD_prp_9


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(ROBERT_FILTER_COEFF,theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(FLDNOW,size(FLDNOW),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(FLDOLD,size(FLDOLD),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(FLDNEW,size(FLDNEW),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(FLDNEW,1),lbound(FLDNEW,1),-1
      FLDNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FLDOLD,1),lbound(FLDOLD,1),-1
      FLDOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FLDNOW,1),lbound(FLDNOW,1),-1
      FLDNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      ROBERT_FILTER_COEFF = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      DO L = 1, 3, 1
        FLDNOW(INT(L))%v = (FLDNOW(L)%v+ROBERT_FILTER_COEFF*(FLDOLD(L)%v
     ++FLDNEW(L)%v-FLDNOW(L)%v*2.0D00))
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_Symbol_26 = 0_w2f__i8
      DO L = 1,3,1
        OpenAD_aux_22 = (FLDOLD(L)%v+FLDNEW(L)%v-FLDNOW(L)%v*2.0D00)
        OpenAD_lin_31 = ROBERT_FILTER_COEFF
        FLDNOW(INT(L))%v = (FLDNOW(L)%v+ROBERT_FILTER_COEFF*OpenAD_aux_2
     +2)
        double_tape(double_tape_pointer) = OpenAD_lin_31
        double_tape_pointer = double_tape_pointer+1
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_26 = (INT(OpenAD_Symbol_26)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_26
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_24 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_25 = 1
      do while (INT(OpenAD_Symbol_25).LE.INT(OpenAD_Symbol_24))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_174 = integer_tape(integer_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_175 = double_tape(double_tape_pointer)
        OpenAD_prp_9%d = OpenAD_prp_9%d+FLDNOW(OpenAD_Symbol_174)%d*(Ope
     +nAD_Symbol_175)
        OpenAD_prp_7%d = OpenAD_prp_7%d+FLDNOW(OpenAD_Symbol_174)%d
        FLDNOW(OpenAD_Symbol_174)%d = 0.0d0
        OpenAD_prp_8%d = OpenAD_prp_8%d+OpenAD_prp_9%d*(-2.0D00)
        FLDNEW(OpenAD_Symbol_174)%d = FLDNEW(OpenAD_Symbol_174)%d+OpenAD
     +_prp_9%d
        FLDOLD(OpenAD_Symbol_174)%d = FLDOLD(OpenAD_Symbol_174)%d+OpenAD
     +_prp_9%d
        OpenAD_prp_9%d = 0.0d0
        FLDNOW(OpenAD_Symbol_174)%d = FLDNOW(OpenAD_Symbol_174)%d+OpenAD
     +_prp_8%d
        OpenAD_prp_8%d = 0.0d0
        FLDNOW(OpenAD_Symbol_174)%d = FLDNOW(OpenAD_Symbol_174)%d+OpenAD
     +_prp_7%d
        OpenAD_prp_7%d = 0.0d0
        OpenAD_Symbol_25 = INT(OpenAD_Symbol_25)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_robert_filter
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_cycle_fields()
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_30
      INTEGER(w2f__i8) OpenAD_Symbol_31
      INTEGER(w2f__i8) OpenAD_Symbol_32
      INTEGER(w2f__i8) OpenAD_Symbol_33
      INTEGER(w2f__i8) OpenAD_Symbol_34
      INTEGER(w2f__i8) OpenAD_Symbol_35
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_176
      INTEGER(w2f__i4) OpenAD_Symbol_177
      type(active) :: OpenAD_prp_10
      type(active) :: OpenAD_prp_11


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_vector(SNEW,size(SNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(SNOW,size(SNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TNEW,size(TNEW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_real_vector(TNOW,size(TNOW),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(TNOW,1),lbound(TNOW,1),-1
      TNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(TNEW,1),lbound(TNEW,1),-1
      TNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNOW,1),lbound(SNOW,1),-1
      SNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(SNEW,1),lbound(SNEW,1),-1
      SNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      DO L = 1, 3, 1
        TOLD(INT(L))%v = TNOW(L)%v
        TNOW(INT(L))%v = TNEW(L)%v
        SOLD(INT(L))%v = SNOW(L)%v
        SNOW(INT(L))%v = SNEW(L)%v
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_Symbol_32 = 0_w2f__i8
      DO L = 1,3,1
        TOLD(INT(L))%v = TNOW(L)%v
        TNOW(INT(L))%v = TNEW(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        SOLD(INT(L))%v = SNOW(L)%v
        SNOW(INT(L))%v = SNEW(L)%v
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_32 = (INT(OpenAD_Symbol_32)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_32
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_30 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_31 = 1
      do while (INT(OpenAD_Symbol_31).LE.INT(OpenAD_Symbol_30))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_176 = integer_tape(integer_tape_pointer)
        SNEW(OpenAD_Symbol_176)%d = SNEW(OpenAD_Symbol_176)%d+SNOW(OpenA
     +D_Symbol_176)%d
        SNOW(OpenAD_Symbol_176)%d = 0.0d0
        OpenAD_prp_11%d = OpenAD_prp_11%d+SOLD(OpenAD_Symbol_176)%d
        SOLD(OpenAD_Symbol_176)%d = 0.0d0
        SNOW(OpenAD_Symbol_176)%d = SNOW(OpenAD_Symbol_176)%d+OpenAD_prp
     +_11%d
        OpenAD_prp_11%d = 0.0d0
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_177 = integer_tape(integer_tape_pointer)
        TNEW(OpenAD_Symbol_177)%d = TNEW(OpenAD_Symbol_177)%d+TNOW(OpenA
     +D_Symbol_177)%d
        TNOW(OpenAD_Symbol_177)%d = 0.0d0
        OpenAD_prp_10%d = OpenAD_prp_10%d+TOLD(OpenAD_Symbol_177)%d
        TOLD(OpenAD_Symbol_177)%d = 0.0d0
        TNOW(OpenAD_Symbol_177)%d = TNOW(OpenAD_Symbol_177)%d+OpenAD_prp
     +_10%d
        OpenAD_prp_10%d = 0.0d0
        OpenAD_Symbol_31 = INT(OpenAD_Symbol_31)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_cycle_fields
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_update(FLDNEW, FLDOLD, DFLDDT)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_145
      INTEGER(w2f__i8) OpenAD_Symbol_146
      INTEGER(w2f__i8) OpenAD_Symbol_147
      INTEGER(w2f__i8) OpenAD_Symbol_148
      INTEGER(w2f__i8) OpenAD_Symbol_149
      INTEGER(w2f__i8) OpenAD_Symbol_150
C
C     **** Parameters and Result ****
C
      type(active) :: FLDNEW(1:3)
      type(active) :: FLDOLD(1:3)
      type(active) :: DFLDDT(1:3)
C
C     **** Local Variables and Functions ****
C
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) L
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      INTEGER(w2f__i4) OpenAD_Symbol_184
      REAL(w2f__8) OpenAD_Symbol_185
      REAL(w2f__8) OpenAD_aux_23
      REAL(w2f__8) OpenAD_lin_32


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_scalar(DELTA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_vector(FLDOLD,size(FLDOLD),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(DFLDDT,size(DFLDDT),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(DFLDDT,1),lbound(DFLDDT,1),-1
      DFLDDT(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FLDOLD,1),lbound(FLDOLD,1),-1
      FLDOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      DELTA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      DO L = 1, 3, 1
        FLDNEW(INT(L))%v = (FLDOLD(L)%v+DFLDDT(L)%v*DELTA_T*2.0D00)
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      OpenAD_Symbol_147 = 0_w2f__i8
      DO L = 1,3,1
        OpenAD_aux_23 = (DELTA_T*2.0D00)
        OpenAD_lin_32 = OpenAD_aux_23
        FLDNEW(INT(L))%v = (FLDOLD(L)%v+DFLDDT(L)%v*OpenAD_aux_23)
        double_tape(double_tape_pointer) = OpenAD_lin_32
        double_tape_pointer = double_tape_pointer+1
        integer_tape(integer_tape_pointer) = L
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_147 = (INT(OpenAD_Symbol_147)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_147
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_145 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_146 = 1
      do while (INT(OpenAD_Symbol_146).LE.INT(OpenAD_Symbol_145))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_184 = integer_tape(integer_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_185 = double_tape(double_tape_pointer)
        DFLDDT(OpenAD_Symbol_184)%d = DFLDDT(OpenAD_Symbol_184)%d+FLDNEW
     +(OpenAD_Symbol_184)%d*(OpenAD_Symbol_185)
        FLDOLD(OpenAD_Symbol_184)%d = FLDOLD(OpenAD_Symbol_184)%d+FLDNEW
     +(OpenAD_Symbol_184)%d
        FLDNEW(OpenAD_Symbol_184)%d = 0.0d0
        OpenAD_Symbol_146 = INT(OpenAD_Symbol_146)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_update
C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################

      SUBROUTINE box_timestep(GAMMALOC, FLDSTAR, EXTFORLOC, UVELLOC, FLD
     +NOW, FLDOLD, FLDNEW)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      use oad_intrinsics
      use all_globals_mod
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_18
      INTEGER(w2f__i8) OpenAD_Symbol_19
      INTEGER(w2f__i8) OpenAD_Symbol_20
      INTEGER(w2f__i8) OpenAD_Symbol_21
      INTEGER(w2f__i8) OpenAD_Symbol_22
      INTEGER(w2f__i8) OpenAD_Symbol_23
C
C     **** Parameters and Result ****
C
      REAL(w2f__8) GAMMALOC
      REAL(w2f__8) FLDSTAR(1 : 2)
      REAL(w2f__8) EXTFORLOC(1 : 2)
      type(active) :: UVELLOC
      type(active) :: FLDNOW(1:3)
      type(active) :: FLDOLD(1:3)
      type(active) :: FLDNEW(1:3)
C
C     **** Local Variables and Functions ****
C
      EXTERNAL box_update
      type(active) :: DFLDDT(1:3)
      INTEGER(w2f__i4) ISBYTE
      PARAMETER ( ISBYTE = 8)
      INTEGER(w2f__i4) NLEV1
      PARAMETER ( NLEV1 = 73)
      INTEGER(w2f__i4) NLEV2
      PARAMETER ( NLEV2 = 50)
      REAL(w2f__8) OpenAD_Symbol_158
      REAL(w2f__8) OpenAD_Symbol_159
      REAL(w2f__8) OpenAD_Symbol_160
      REAL(w2f__8) OpenAD_Symbol_161
      REAL(w2f__8) OpenAD_Symbol_162
      REAL(w2f__8) OpenAD_Symbol_163
      REAL(w2f__8) OpenAD_Symbol_164
      REAL(w2f__8) OpenAD_Symbol_165
      REAL(w2f__8) OpenAD_Symbol_166
      REAL(w2f__8) OpenAD_Symbol_167
      REAL(w2f__8) OpenAD_Symbol_168
      REAL(w2f__8) OpenAD_Symbol_169
      REAL(w2f__8) OpenAD_Symbol_170
      REAL(w2f__8) OpenAD_Symbol_171
      REAL(w2f__8) OpenAD_Symbol_172
      REAL(w2f__8) OpenAD_Symbol_173
      REAL(w2f__8) OpenAD_acc_10
      REAL(w2f__8) OpenAD_acc_11
      REAL(w2f__8) OpenAD_acc_12
      REAL(w2f__8) OpenAD_acc_13
      REAL(w2f__8) OpenAD_acc_14
      REAL(w2f__8) OpenAD_acc_15
      REAL(w2f__8) OpenAD_acc_16
      REAL(w2f__8) OpenAD_acc_17
      REAL(w2f__8) OpenAD_acc_18
      REAL(w2f__8) OpenAD_acc_19
      REAL(w2f__8) OpenAD_acc_2
      REAL(w2f__8) OpenAD_acc_3
      REAL(w2f__8) OpenAD_acc_4
      REAL(w2f__8) OpenAD_acc_5
      REAL(w2f__8) OpenAD_acc_6
      REAL(w2f__8) OpenAD_acc_7
      REAL(w2f__8) OpenAD_acc_8
      REAL(w2f__8) OpenAD_acc_9
      REAL(w2f__8) OpenAD_aux_10
      REAL(w2f__8) OpenAD_aux_11
      REAL(w2f__8) OpenAD_aux_12
      REAL(w2f__8) OpenAD_aux_13
      REAL(w2f__8) OpenAD_aux_14
      REAL(w2f__8) OpenAD_aux_15
      REAL(w2f__8) OpenAD_aux_16
      REAL(w2f__8) OpenAD_aux_17
      REAL(w2f__8) OpenAD_aux_18
      REAL(w2f__8) OpenAD_aux_19
      REAL(w2f__8) OpenAD_aux_2
      REAL(w2f__8) OpenAD_aux_20
      REAL(w2f__8) OpenAD_aux_21
      REAL(w2f__8) OpenAD_aux_3
      REAL(w2f__8) OpenAD_aux_4
      REAL(w2f__8) OpenAD_aux_5
      REAL(w2f__8) OpenAD_aux_6
      REAL(w2f__8) OpenAD_aux_7
      REAL(w2f__8) OpenAD_aux_8
      REAL(w2f__8) OpenAD_aux_9
      REAL(w2f__8) OpenAD_lin_10
      REAL(w2f__8) OpenAD_lin_11
      REAL(w2f__8) OpenAD_lin_12
      REAL(w2f__8) OpenAD_lin_13
      REAL(w2f__8) OpenAD_lin_14
      REAL(w2f__8) OpenAD_lin_15
      REAL(w2f__8) OpenAD_lin_16
      REAL(w2f__8) OpenAD_lin_17
      REAL(w2f__8) OpenAD_lin_18
      REAL(w2f__8) OpenAD_lin_19
      REAL(w2f__8) OpenAD_lin_20
      REAL(w2f__8) OpenAD_lin_21
      REAL(w2f__8) OpenAD_lin_22
      REAL(w2f__8) OpenAD_lin_23
      REAL(w2f__8) OpenAD_lin_24
      REAL(w2f__8) OpenAD_lin_25
      REAL(w2f__8) OpenAD_lin_26
      REAL(w2f__8) OpenAD_lin_27
      REAL(w2f__8) OpenAD_lin_28
      REAL(w2f__8) OpenAD_lin_29
      REAL(w2f__8) OpenAD_lin_30
      REAL(w2f__8) OpenAD_lin_5
      REAL(w2f__8) OpenAD_lin_6
      REAL(w2f__8) OpenAD_lin_7
      REAL(w2f__8) OpenAD_lin_8
      REAL(w2f__8) OpenAD_lin_9
      type(active) :: OpenAD_prp_1
      type(active) :: OpenAD_prp_2
      type(active) :: OpenAD_prp_3
      type(active) :: OpenAD_prp_4
      type(active) :: OpenAD_prp_5
      type(active) :: OpenAD_prp_6


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
      call cp_store_real_vector(FLDOLD,size(FLDOLD),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_vector(FLDNEW,size(FLDNEW),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
      call cp_store_real_scalar(DELTA_T,theArgFStack,theArgFStackoffset,
     +theArgFStackSize)
      call cp_store_real_scalar(GAMMALOC,theArgFStack,theArgFStackoffset
     +,theArgFStackSize)
      call cp_store_real_scalar(UVELLOC%v,theArgFStack,theArgFStackoffse
     +t,theArgFStackSize)
      call cp_store_p_real_vector(VOL,size(VOL),theArgFStack,theArgFStac
     +koffset,theArgFStackSize)
      call cp_store_p_real_vector(FLDSTAR,size(FLDSTAR),theArgFStack,the
     +ArgFStackoffset,theArgFStackSize)
      call cp_store_p_real_vector(EXTFORLOC,size(EXTFORLOC),theArgFStack
     +,theArgFStackoffset,theArgFStackSize)
      call cp_store_real_vector(FLDNOW,size(FLDNOW),theArgFStack,theArgF
     +Stackoffset,theArgFStackSize)
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
      do cp_loop_variable_1 = ubound(FLDNOW,1),lbound(FLDNOW,1),-1
      FLDNOW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(EXTFORLOC,1),lbound(EXTFORLOC,1),-1
      EXTFORLOC(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FLDSTAR,1),lbound(FLDSTAR,1),-1
      FLDSTAR(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(VOL,1),lbound(VOL,1),-1
      VOL(cp_loop_variable_1) = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      UVELLOC%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      GAMMALOC = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      DELTA_T = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      do cp_loop_variable_1 = ubound(FLDNEW,1),lbound(FLDNEW,1),-1
      FLDNEW(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
      do cp_loop_variable_1 = ubound(FLDOLD,1),lbound(FLDOLD,1),-1
      FLDOLD(cp_loop_variable_1)%v = theArgFStack(theArgFStackoffset)
      theArgFStackoffset = theArgFStackoffset-1
      end do
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      IF (UVELLOC%v.GE.0.0D00) THEN
        DFLDDT(1)%v = ((EXTFORLOC(1)+VOL(1)*GAMMALOC*(FLDSTAR(1)-FLDNOW(
     +1)%v)+UVELLOC%v*(FLDNOW(3)%v-FLDNOW(1)%v))/VOL(1))
        DFLDDT(2)%v = ((EXTFORLOC(2)+VOL(2)*GAMMALOC*(FLDSTAR(2)-FLDNOW(
     +2)%v)+UVELLOC%v*(FLDNOW(1)%v-FLDNOW(2)%v))/VOL(2))
        DFLDDT(3)%v = ((UVELLOC%v*(FLDNOW(2)%v-FLDNOW(3)%v))/VOL(3))
      ELSE
        DFLDDT(1)%v = ((EXTFORLOC(1)+VOL(1)*GAMMALOC*(FLDSTAR(1)-FLDNOW(
     +1)%v)-UVELLOC%v*(FLDNOW(2)%v-FLDNOW(1)%v))/VOL(1))
        DFLDDT(2)%v = ((EXTFORLOC(2)+VOL(2)*GAMMALOC*(FLDSTAR(2)-FLDNOW(
     +2)%v)-UVELLOC%v*(FLDNOW(3)%v-FLDNOW(2)%v))/VOL(2))
        DFLDDT(3)%v = (-((UVELLOC%v*(FLDNOW(1)%v-FLDNOW(3)%v))/VOL(3)))
      ENDIF
      CALL box_update(FLDNEW,FLDOLD,DFLDDT)

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      IF (UVELLOC%v.GE.0.0D00) THEN
        OpenAD_aux_4 = (FLDSTAR(1)-FLDNOW(1)%v)
        OpenAD_aux_3 = (GAMMALOC*OpenAD_aux_4)
        OpenAD_aux_5 = (FLDNOW(3)%v-FLDNOW(1)%v)
        OpenAD_aux_2 = (EXTFORLOC(1)+VOL(1)*OpenAD_aux_3+UVELLOC%v*OpenA
     +D_aux_5)
        OpenAD_lin_7 = GAMMALOC
        OpenAD_lin_6 = VOL(1)
        OpenAD_lin_8 = OpenAD_aux_5
        OpenAD_lin_9 = UVELLOC%v
        OpenAD_lin_5 = (INT(1_w2f__i8)/VOL(1))
        DFLDDT(1)%v = (OpenAD_aux_2/VOL(1))
        OpenAD_acc_2 = (OpenAD_lin_8*OpenAD_lin_5)
        OpenAD_acc_3 = (OpenAD_lin_9*OpenAD_lin_5)
        OpenAD_acc_4 = (INT((-1_w2f__i8))*OpenAD_lin_7*OpenAD_lin_6*Open
     +AD_lin_5)
        double_tape(double_tape_pointer) = OpenAD_acc_2
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_3
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_4
        double_tape_pointer = double_tape_pointer+1
        OpenAD_aux_8 = (FLDSTAR(2)-FLDNOW(2)%v)
        OpenAD_aux_7 = (GAMMALOC*OpenAD_aux_8)
        OpenAD_aux_9 = (FLDNOW(1)%v-FLDNOW(2)%v)
        OpenAD_aux_6 = (EXTFORLOC(2)+VOL(2)*OpenAD_aux_7+UVELLOC%v*OpenA
     +D_aux_9)
        OpenAD_lin_12 = GAMMALOC
        OpenAD_lin_11 = VOL(2)
        OpenAD_lin_13 = OpenAD_aux_9
        OpenAD_lin_14 = UVELLOC%v
        OpenAD_lin_10 = (INT(1_w2f__i8)/VOL(2))
        DFLDDT(2)%v = (OpenAD_aux_6/VOL(2))
        OpenAD_acc_5 = (OpenAD_lin_13*OpenAD_lin_10)
        OpenAD_acc_6 = (OpenAD_lin_14*OpenAD_lin_10)
        OpenAD_acc_7 = (INT((-1_w2f__i8))*OpenAD_lin_12*OpenAD_lin_11*Op
     +enAD_lin_10)
        double_tape(double_tape_pointer) = OpenAD_acc_5
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_6
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_7
        double_tape_pointer = double_tape_pointer+1
        OpenAD_aux_11 = (FLDNOW(2)%v-FLDNOW(3)%v)
        OpenAD_aux_10 = (UVELLOC%v*OpenAD_aux_11)
        OpenAD_lin_16 = OpenAD_aux_11
        OpenAD_lin_17 = UVELLOC%v
        OpenAD_lin_15 = (INT(1_w2f__i8)/VOL(3))
        DFLDDT(3)%v = (OpenAD_aux_10/VOL(3))
        OpenAD_acc_8 = (OpenAD_lin_16*OpenAD_lin_15)
        OpenAD_acc_9 = (OpenAD_lin_17*OpenAD_lin_15)
        double_tape(double_tape_pointer) = OpenAD_acc_8
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_9
        double_tape_pointer = double_tape_pointer+1
        OpenAD_Symbol_19 = 1_w2f__i8
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_19
        integer_tape_pointer = integer_tape_pointer+1
      ELSE
        OpenAD_aux_14 = (FLDSTAR(1)-FLDNOW(1)%v)
        OpenAD_aux_13 = (GAMMALOC*OpenAD_aux_14)
        OpenAD_aux_15 = (FLDNOW(2)%v-FLDNOW(1)%v)
        OpenAD_aux_12 = (EXTFORLOC(1)+VOL(1)*OpenAD_aux_13-UVELLOC%v*Ope
     +nAD_aux_15)
        OpenAD_lin_20 = GAMMALOC
        OpenAD_lin_19 = VOL(1)
        OpenAD_lin_21 = OpenAD_aux_15
        OpenAD_lin_22 = UVELLOC%v
        OpenAD_lin_18 = (INT(1_w2f__i8)/VOL(1))
        DFLDDT(1)%v = (OpenAD_aux_12/VOL(1))
        OpenAD_acc_10 = (INT((-1_w2f__i8))*OpenAD_lin_18)
        OpenAD_acc_11 = (OpenAD_lin_21*OpenAD_acc_10)
        OpenAD_acc_12 = (OpenAD_lin_22*OpenAD_acc_10)
        OpenAD_acc_13 = (INT((-1_w2f__i8))*OpenAD_lin_20*OpenAD_lin_19*O
     +penAD_lin_18)
        double_tape(double_tape_pointer) = OpenAD_acc_11
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_12
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_13
        double_tape_pointer = double_tape_pointer+1
        OpenAD_aux_18 = (FLDSTAR(2)-FLDNOW(2)%v)
        OpenAD_aux_17 = (GAMMALOC*OpenAD_aux_18)
        OpenAD_aux_19 = (FLDNOW(3)%v-FLDNOW(2)%v)
        OpenAD_aux_16 = (EXTFORLOC(2)+VOL(2)*OpenAD_aux_17-UVELLOC%v*Ope
     +nAD_aux_19)
        OpenAD_lin_25 = GAMMALOC
        OpenAD_lin_24 = VOL(2)
        OpenAD_lin_26 = OpenAD_aux_19
        OpenAD_lin_27 = UVELLOC%v
        OpenAD_lin_23 = (INT(1_w2f__i8)/VOL(2))
        DFLDDT(2)%v = (OpenAD_aux_16/VOL(2))
        OpenAD_acc_14 = (INT((-1_w2f__i8))*OpenAD_lin_23)
        OpenAD_acc_15 = (OpenAD_lin_26*OpenAD_acc_14)
        OpenAD_acc_16 = (OpenAD_lin_27*OpenAD_acc_14)
        OpenAD_acc_17 = (INT((-1_w2f__i8))*OpenAD_lin_25*OpenAD_lin_24*O
     +penAD_lin_23)
        double_tape(double_tape_pointer) = OpenAD_acc_15
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_16
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_17
        double_tape_pointer = double_tape_pointer+1
        OpenAD_aux_21 = (FLDNOW(1)%v-FLDNOW(3)%v)
        OpenAD_aux_20 = (UVELLOC%v*OpenAD_aux_21)
        OpenAD_lin_29 = OpenAD_aux_21
        OpenAD_lin_30 = UVELLOC%v
        OpenAD_lin_28 = (INT(1_w2f__i8)/VOL(3))
        DFLDDT(3)%v = (-(OpenAD_aux_20/VOL(3)))
        OpenAD_acc_18 = (OpenAD_lin_29*OpenAD_lin_28*INT((-1_w2f__i8)))
        OpenAD_acc_19 = (OpenAD_lin_30*OpenAD_lin_28*INT((-1_w2f__i8)))
        double_tape(double_tape_pointer) = OpenAD_acc_18
        double_tape_pointer = double_tape_pointer+1
        double_tape(double_tape_pointer) = OpenAD_acc_19
        double_tape_pointer = double_tape_pointer+1
        OpenAD_Symbol_20 = 0_w2f__i8
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_20
        integer_tape_pointer = integer_tape_pointer+1
      ENDIF
      CALL box_update(FLDNEW,FLDOLD,DFLDDT)

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      CALL box_update(FLDNEW,FLDOLD,DFLDDT)
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_18 = integer_tape(integer_tape_pointer)
      IF (OpenAD_Symbol_18.ne.0) THEN
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_158 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_159 = double_tape(double_tape_pointer)
        OpenAD_prp_3%d = OpenAD_prp_3%d+DFLDDT(3)%d*(OpenAD_Symbol_158)
        UVELLOC%d = UVELLOC%d+DFLDDT(3)%d*(OpenAD_Symbol_159)
        DFLDDT(3)%d = 0.0d0
        FLDNOW(3)%d = FLDNOW(3)%d-OpenAD_prp_3%d
        FLDNOW(2)%d = FLDNOW(2)%d+OpenAD_prp_3%d
        OpenAD_prp_3%d = 0.0d0
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_160 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_161 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_162 = double_tape(double_tape_pointer)
        FLDNOW(2)%d = FLDNOW(2)%d+DFLDDT(2)%d*(OpenAD_Symbol_160)
        OpenAD_prp_2%d = OpenAD_prp_2%d+DFLDDT(2)%d*(OpenAD_Symbol_161)
        UVELLOC%d = UVELLOC%d+DFLDDT(2)%d*(OpenAD_Symbol_162)
        DFLDDT(2)%d = 0.0d0
        FLDNOW(2)%d = FLDNOW(2)%d-OpenAD_prp_2%d
        FLDNOW(1)%d = FLDNOW(1)%d+OpenAD_prp_2%d
        OpenAD_prp_2%d = 0.0d0
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_163 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_164 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_165 = double_tape(double_tape_pointer)
        FLDNOW(1)%d = FLDNOW(1)%d+DFLDDT(1)%d*(OpenAD_Symbol_163)
        OpenAD_prp_1%d = OpenAD_prp_1%d+DFLDDT(1)%d*(OpenAD_Symbol_164)
        UVELLOC%d = UVELLOC%d+DFLDDT(1)%d*(OpenAD_Symbol_165)
        DFLDDT(1)%d = 0.0d0
        FLDNOW(1)%d = FLDNOW(1)%d-OpenAD_prp_1%d
        FLDNOW(3)%d = FLDNOW(3)%d+OpenAD_prp_1%d
        OpenAD_prp_1%d = 0.0d0
      ELSE
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_166 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_167 = double_tape(double_tape_pointer)
        OpenAD_prp_6%d = OpenAD_prp_6%d+DFLDDT(3)%d*(OpenAD_Symbol_166)
        UVELLOC%d = UVELLOC%d+DFLDDT(3)%d*(OpenAD_Symbol_167)
        DFLDDT(3)%d = 0.0d0
        FLDNOW(3)%d = FLDNOW(3)%d-OpenAD_prp_6%d
        FLDNOW(1)%d = FLDNOW(1)%d+OpenAD_prp_6%d
        OpenAD_prp_6%d = 0.0d0
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_168 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_169 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_170 = double_tape(double_tape_pointer)
        FLDNOW(2)%d = FLDNOW(2)%d+DFLDDT(2)%d*(OpenAD_Symbol_168)
        OpenAD_prp_5%d = OpenAD_prp_5%d+DFLDDT(2)%d*(OpenAD_Symbol_169)
        UVELLOC%d = UVELLOC%d+DFLDDT(2)%d*(OpenAD_Symbol_170)
        DFLDDT(2)%d = 0.0d0
        FLDNOW(2)%d = FLDNOW(2)%d-OpenAD_prp_5%d
        FLDNOW(3)%d = FLDNOW(3)%d+OpenAD_prp_5%d
        OpenAD_prp_5%d = 0.0d0
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_171 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_172 = double_tape(double_tape_pointer)
        double_tape_pointer = double_tape_pointer-1
        OpenAD_Symbol_173 = double_tape(double_tape_pointer)
        FLDNOW(1)%d = FLDNOW(1)%d+DFLDDT(1)%d*(OpenAD_Symbol_171)
        OpenAD_prp_4%d = OpenAD_prp_4%d+DFLDDT(1)%d*(OpenAD_Symbol_172)
        UVELLOC%d = UVELLOC%d+DFLDDT(1)%d*(OpenAD_Symbol_173)
        DFLDDT(1)%d = 0.0d0
        FLDNOW(1)%d = FLDNOW(1)%d-OpenAD_prp_4%d
        FLDNOW(2)%d = FLDNOW(2)%d+OpenAD_prp_4%d
        OpenAD_prp_4%d = 0.0d0
      ENDIF

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine box_timestep
